package app.fugema.shop.main.center.vm;

import android.app.Application;

import com.base.common.netBeanPackage.BaseApiResult;
import com.base.common.netBeanPackage.LiveDataWrapper;
import com.base.common.viewmodel.BaseViewModel;
import app.fugema.shop.http.HttpService;
import app.fugema.shop.main.center.model.GiftOrderBean;
import app.fugema.shop.main.center.model.GiftOrderCountResult;
import app.fugema.shop.main.center.model.GiftOrdersDetailResult;
import app.fugema.shop.main.center.model.GiftOrdersResult;
import app.fugema.shop.main.order.model.OrderDetailResult;

import java.util.HashMap;
import java.util.Map;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import app.fugema.shop.main.order.model.OrderExpressResult;

public class JiFenOrderVM extends BaseViewModel
{

    public JiFenOrderVM(@NonNull Application application)
    {
        super(application);
    }


    /**
     * 查询 积分订单列表
     * @param status
     * @param page
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<GiftOrdersResult>> getMyGiftOrders(int status, int page, String userKey)
    {
        //status=0&page=1&userkey=Z
        Map<String,Object> params = new HashMap<>();
        params.put("status", status);
        params.put("page", page);
        // 不知道 有没有
        //params.put("pagesize", 15);
        params.put("userkey", userKey);

        return send(HttpService.getHttpServer().getGiftOrderList(params));
    }

    /**
     * 订单详情信息
     * @param orderId
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<GiftOrdersDetailResult>> getOrderDetail(long orderId, String userKey)
    {
        return send(HttpService.getHttpServer().getGiftOrderDetail(orderId ,userKey));
    }

    /**
     * 查询  积分兑换 订单数量
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<GiftOrderCountResult>> getGiftOrderCount(String userKey)
    {
        return send(HttpService.getHttpServer().getGiftOrderCount(userKey));
    }

    /**
     *  积分订单 确认收货
     * @param orderId
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<BaseApiResult>> confirmGiftOrder(long orderId, String userKey)
    {
        return send(HttpService.getHttpServer().confirmGiftOrder(orderId,userKey));
    }

    /**
     * 查询订单物流 信息
     * @param orderNumber
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<OrderExpressResult>> checkOrderExpressInfo(long orderNumber , String userKey)
    {
        return send(HttpService.getHttpServer().getGiftExpressInfo(orderNumber,userKey));
    }
}
